Valid for Sitecore
5.2, 5.1.1
Mapping Data Source IDs to GUIDs
Prev Next |
Sitecore uses GUIDs to uniquely reference items. Items served by external data sources must also be referenced in Sitecore via a unique GUID. On the other hand, items in external data sources have most likely been assigned a unique identifier by the external data source. The data provider must use this identifier to locate the item in the external data source. In order to resolve this issue, the data provider developer must create a mechanism to map between the externally defined identifier and the Sitecore GUIDs. There are several ways to do this.
-
IDTable Mapping
Sitecore 5.1.1 introduced the IDTable class, which provides persistent mapping between GUIDs and external IDs. This is the preferred approach to mapping IDs. Please refer to the Sitecore.Data.IDTables.IDTable Reference section for more information about this class.
-
Dynamic Mapping
Sitecore's ID class provides the NewID method, which creates a unique GUID. One approach to mapping GUIDs to IDs is to generate GUIDs for items as the items are retrieved and map them in memory to the item's own unique ID. The drawback with this approach is that GUIDs for items will then change when the Sitecore processes are restarted. This can cause problems, particularly if the items are published. Therefore, this method is not recommended.
-
Manual Mapping
Data providers may also implement their own mapping mechanism. For example, developers could create an SQL table to hold ID to GUID mapping information. This approach is acceptable, but most likely requires more work than using the IDTable mapping described above.
Prev Next